package view;

import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionListener;

import javax.swing.Box;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JSplitPane;


public class MainWindow extends JFrame{
	
	private static final long serialVersionUID = 1L;

	private MenuBar menu;
	private Form form;
	private SimulationTelevision simTV;
	private CommunicationArea log;
	
	/**
	 * MainWindow constructor
	 */
	public MainWindow(ActionListener al){
		setMinimumSize(new Dimension(800,550));
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		//setExtendedState(MAXIMIZED_BOTH);
		setLayout(new GridBagLayout());
		menu = new MenuBar(al);
		add(menu, new GridBagConstraints(0,0,5,1,1.0,0,GridBagConstraints.PAGE_START,GridBagConstraints.HORIZONTAL,new Insets(0,0,0,0),0,0));
		form = new Form();
		add(Box.createHorizontalGlue(),new GridBagConstraints(0,1,1,1,1.0,0,GridBagConstraints.CENTER,GridBagConstraints.HORIZONTAL,new Insets(0,0,0,0),0,0));
		add(form, new GridBagConstraints(1,1,3,1,0,0,GridBagConstraints.PAGE_START,GridBagConstraints.NONE,new Insets(10,0,0,0),0,0));
		add(Box.createHorizontalGlue(),new GridBagConstraints(4,1,1,1,1.0,0,GridBagConstraints.CENTER,GridBagConstraints.HORIZONTAL,new Insets(0,0,0,0),0,0));
		simTV = new SimulationTelevision();
		add(Box.createHorizontalGlue(),new GridBagConstraints(0,2,1,1,1.0,1.0,GridBagConstraints.CENTER,GridBagConstraints.HORIZONTAL,new Insets(0,0,0,0),0,0));
		add(simTV, new GridBagConstraints(1,2,3,1,1.0,1.0,GridBagConstraints.CENTER,GridBagConstraints.BOTH,new Insets(0,0,0,0),0,0));
		add(Box.createHorizontalGlue(),new GridBagConstraints(4,2,1,1,1.0,1.0,GridBagConstraints.CENTER,GridBagConstraints.HORIZONTAL,new Insets(0,0,0,0),0,0));
		log = new CommunicationArea();
		JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,Box.createVerticalGlue(),log);
		splitPane.setOneTouchExpandable(true);
		splitPane.setContinuousLayout(true);
		splitPane.setResizeWeight(1);
		splitPane.setBorder(null);
		add(splitPane, new GridBagConstraints(0,3,5,1,0,0,GridBagConstraints.FIRST_LINE_START,GridBagConstraints.BOTH,new Insets(0,0,0,0),0,0));
	}
	
	/**
	 * 
	 * @return the menu bar
	 */
	public MenuBar getMenu(){
		return menu;
	}
	
	/**
	 * 
	 * @return the input form
	 */
	public Form getForm(){
		return form;
	}
	

	public SimulationTelevision getSimulationTelevision(){
		return simTV;
	}
	
	/**
	 * 
	 * @return the log
	 */
	public CommunicationArea getLogArea(){
		return log;
	}

	
	
}
